from django.db import models
from django.contrib import admin

class Fiction(models.Model):
    name = models.CharField(max_length = 30)
    url = models.URLField()
    last_modified_time = models.CharField(max_length = 50)
    new_tag = models.BooleanField()
    
class Chapter(models.Model):
    fiction = models.ForeignKey(Fiction)
    chapter = models.CharField(max_length = 100)
    
class ChoiceInline(admin.StackedInline):
    model = Chapter
    extra = 0

class FictionAdmin(admin.ModelAdmin):
    fields = ['name', 'url', 'last_modified_time', 'new_tag']
    list_display = ('name', 'url')
    inlines = [ChoiceInline]

admin.site.register(Fiction, FictionAdmin)

class ChapterAdmin(admin.ModelAdmin):
    fields = ['fiction', 'chapter']
    list_display = ('fiction', 'chapter')

admin.site.register(Chapter, ChapterAdmin)
